<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#375EAB">
<title>Gosl &ndash; package mpi</title>
<link type="text/css" rel="stylesheet" href="static/style.css">
<script type="text/javascript" src="static/godocs.js"></script>
<style type="text/css"></style>
</head>
<body>
<div id="page" class=\wide">
<div class="container">
<h1>Gosl &ndash; <b>mpi</b> &ndash; Message Passing Interface for parallel computing</h1>
use 'godoc cmd/github.com/cpmech/gosl/mpi' for documentation on the github.com/cpmech/gosl/mpi command 

<!--
	Copyright 2009 The Go Authors. All rights reserved.
	Use of this source code is governed by a BSD-style
	license that can be found in the LICENSE file.
-->
<!--
	Note: Static (i.e., not template-generated) href and id
	attributes start with "pkg-" to make it impossible for
	them to conflict with generated attributes (some of which
	correspond to Go identifiers).
-->

	<script type='text/javascript'>
	document.ANALYSIS_DATA = ;
	document.CALLGRAPH = ;
	</script>

	
		
		<div id="short-nav">
			<dl>
			<dd><code>import "github.com/cpmech/gosl/mpi"</code></dd>
			</dl>
			<dl>
			<dd><a href="#pkg-overview" class="overviewLink">Overview</a></dd>
			<dd><a href="#pkg-index" class="indexLink">Index</a></dd>
			
			
			</dl>
		</div>
		<!-- The package's Name is printed as title by the top-level template -->
		<div id="pkg-overview" class="toggleVisible">
			<div class="collapsed">
				<h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
			</div>
			<div class="expanded">
				<h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
				
			</div>
		</div>
		

		<div id="pkg-index" class="toggleVisible">
		<div class="collapsed">
			<h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
		</div>
		<div class="expanded">
			<h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>

		<!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
			<div id="manual-nav">
			<dl>
			
			
			
				
				<dd><a href="#Abort">func Abort()</a></dd>
			
				
				<dd><a href="#AllReduceMax">func AllReduceMax(x, w []float64)</a></dd>
			
				
				<dd><a href="#AllReduceMin">func AllReduceMin(x, w []float64)</a></dd>
			
				
				<dd><a href="#AllReduceSum">func AllReduceSum(x, w []float64)</a></dd>
			
				
				<dd><a href="#AllReduceSumAdd">func AllReduceSumAdd(y, x, w []float64)</a></dd>
			
				
				<dd><a href="#Barrier">func Barrier()</a></dd>
			
				
				<dd><a href="#BcastFromRoot">func BcastFromRoot(x []float64)</a></dd>
			
				
				<dd><a href="#DblRecv">func DblRecv(vals []float64, from_proc int)</a></dd>
			
				
				<dd><a href="#DblSend">func DblSend(vals []float64, to_proc int)</a></dd>
			
				
				<dd><a href="#IntAllReduceMax">func IntAllReduceMax(x, w []int)</a></dd>
			
				
				<dd><a href="#IntRecv">func IntRecv(vals []int, from_proc int)</a></dd>
			
				
				<dd><a href="#IntSend">func IntSend(vals []int, to_proc int)</a></dd>
			
				
				<dd><a href="#IsOn">func IsOn() bool</a></dd>
			
				
				<dd><a href="#Rank">func Rank() int</a></dd>
			
				
				<dd><a href="#SingleIntRecv">func SingleIntRecv(from_proc int) (val int)</a></dd>
			
				
				<dd><a href="#SingleIntSend">func SingleIntSend(val, to_proc int)</a></dd>
			
				
				<dd><a href="#Size">func Size() int</a></dd>
			
				
				<dd><a href="#Start">func Start(debug bool)</a></dd>
			
				
				<dd><a href="#Stop">func Stop(debug bool)</a></dd>
			
				
				<dd><a href="#SumToRoot">func SumToRoot(dest, orig []float64)</a></dd>
			
			
			
			</dl>
			</div><!-- #manual-nav -->

		

		
			<h4>Package files</h4>
			<p>
			<span style="font-size:90%">
			
				<a href="/src/github.com/cpmech/gosl/mpi/mpi.go">mpi.go</a>
			
			</span>
			</p>
		
		</div><!-- .expanded -->
		</div><!-- #pkg-index -->

		<div id="pkg-callgraph" class="toggle" style="display: none">
		<div class="collapsed">
			<h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
		</div> <!-- .expanded -->
		<div class="expanded">
			<h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
			<p>
			  In the call graph viewer below, each node
			  is a function belonging to this package
			  and its children are the functions it
			  calls&mdash;perhaps dynamically.
			</p>
			<p>
			  The root nodes are the entry points of the
			  package: functions that may be called from
			  outside the package.
			  There may be non-exported or anonymous
			  functions among them if they are called
			  dynamically from another package.
			</p>
			<p>
			  Click a node to visit that function's source code.
			  From there you can visit its callers by
			  clicking its declaring <code>func</code>
			  token.
			</p>
			<p>
			  Functions may be omitted if they were
			  determined to be unreachable in the
			  particular programs or tests that were
			  analyzed.
			</p>
			<!-- Zero means show all package entry points. -->
			<ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
		</div>
		</div> <!-- #pkg-callgraph -->

		
		
		
			
			
			<h2 id="Abort">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=716:728#L18">Abort</a></h2>
			<pre>func Abort()</pre>
			<p>
Abort aborts MPI
</p>

			
			

		
			
			
			<h2 id="AllReduceMax">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=3690:3723#L124">AllReduceMax</a></h2>
			<pre>func AllReduceMax(x, w []<a href="/pkg/builtin/#float64">float64</a>)</pre>
			<p>
AllReduceMax combines all values in &#39;x&#39; from all processors. When corresponding components (at the
same position) exist in a number of processors, the maximum value is selected.
&#39;w&#39; is a workspace with length = len(x). The operations are:
</p>
<pre>w := join_all_selecting_max(x)
x := w
</pre>

			
			

		
			
			
			<h2 id="AllReduceMin">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=3159:3192#L109">AllReduceMin</a></h2>
			<pre>func AllReduceMin(x, w []<a href="/pkg/builtin/#float64">float64</a>)</pre>
			<p>
AllReduceMin combines all values in &#39;x&#39; from all processors. When corresponding components (at the
same position) exist in a number of processors, the minimum value is selected.
&#39;w&#39; is a workspace with length = len(x). The operations are:
</p>
<pre>w := join_all_selecting_min(x)
x := w
</pre>

			
			

		
			
			
			<h2 id="AllReduceSum">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=2110:2143#L79">AllReduceSum</a></h2>
			<pre>func AllReduceSum(x, w []<a href="/pkg/builtin/#float64">float64</a>)</pre>
			<p>
AllReduceSum combines all values in &#39;x&#39; from all processors. Corresponding components in
slice &#39;x&#39; are added together. &#39;w&#39; is a workspace with length = len(x). The operations are:
</p>
<pre>w := join_all_with_sum(x)
x := w
</pre>

			
			

		
			
			
			<h2 id="AllReduceSumAdd">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=2621:2660#L94">AllReduceSumAdd</a></h2>
			<pre>func AllReduceSumAdd(y, x, w []<a href="/pkg/builtin/#float64">float64</a>)</pre>
			<p>
AllReduceSumAdd combines all values in &#39;x&#39; from all processors and adds the result to another
slice &#39;y&#39;. Corresponding components in slice &#39;x&#39; are added together.
&#39;w&#39; is a workspace with length = len(x). The operations are:
</p>
<pre>w := join_all_with_sum(x)
y += w
</pre>

			
			

		
			
			
			<h2 id="Barrier">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=1323:1337#L60">Barrier</a></h2>
			<pre>func Barrier()</pre>
			<p>
Barrier forces synchronisation
</p>

			
			

		
			
			
			<h2 id="BcastFromRoot">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=1776:1807#L71">BcastFromRoot</a></h2>
			<pre>func BcastFromRoot(x []<a href="/pkg/builtin/#float64">float64</a>)</pre>
			<p>
BcastFromRoot broadcasts &#39;x&#39; slice from root (Rank == 0) to all other processors
</p>

			
			

		
			
			
			<h2 id="DblRecv">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=5660:5703#L182">DblRecv</a></h2>
			<pre>func DblRecv(vals []<a href="/pkg/builtin/#float64">float64</a>, from_proc <a href="/pkg/builtin/#int">int</a>)</pre>
			<p>
DblRecv receives a slice of floats from processor &#39;from_proc&#39;
</p>
<pre>NOTE: &#39;vals&#39; must be pre-allocated with the right number of values that will
      be sent by &#39;from_proc&#39;
</pre>

			
			

		
			
			
			<h2 id="DblSend">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=5350:5391#L175">DblSend</a></h2>
			<pre>func DblSend(vals []<a href="/pkg/builtin/#float64">float64</a>, to_proc <a href="/pkg/builtin/#int">int</a>)</pre>
			<p>
DblSend sends a slice of floats to processor &#39;to_proc&#39;
</p>

			
			

		
			
			
			<h2 id="IntAllReduceMax">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=4230:4262#L139">IntAllReduceMax</a></h2>
			<pre>func IntAllReduceMax(x, w []<a href="/pkg/builtin/#int">int</a>)</pre>
			<p>
IntAllReduceMax combines all (int) values in &#39;x&#39; from all processors. When corresponding components (at the
same position) exist in a number of processors, the maximum value is selected.
&#39;w&#39; is a workspace with length = len(x). The operations are:
</p>
<pre>w := join_all_selecting_max(x)
x := w
</pre>

			
			

		
			
			
			<h2 id="IntRecv">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=5164:5203#L170">IntRecv</a></h2>
			<pre>func IntRecv(vals []<a href="/pkg/builtin/#int">int</a>, from_proc <a href="/pkg/builtin/#int">int</a>)</pre>
			<p>
IntRecv receives a slice of integers from processor &#39;from_proc&#39;
</p>
<pre>NOTE: &#39;vals&#39; must be pre-allocated with the right number of values that will
      be sent by &#39;from_proc&#39;
</pre>

			
			

		
			
			
			<h2 id="IntSend">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=4859:4896#L163">IntSend</a></h2>
			<pre>func IntSend(vals []<a href="/pkg/builtin/#int">int</a>, to_proc <a href="/pkg/builtin/#int">int</a>)</pre>
			<p>
IntSend sends a slice of integers to processor &#39;to_proc&#39;
</p>

			
			

		
			
			
			<h2 id="IsOn">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=831:847#L24">IsOn</a></h2>
			<pre>func IsOn() <a href="/pkg/builtin/#bool">bool</a></pre>
			<p>
InOn tells whether MPI is on or not
</p>
<pre>NOTE: this returns true even after Stop
</pre>

			
			

		
			
			
			<h2 id="Rank">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=1156:1171#L50">Rank</a></h2>
			<pre>func Rank() <a href="/pkg/builtin/#int">int</a></pre>
			<p>
Rank returns the processor rank/ID
</p>

			
			

		
			
			
			<h2 id="SingleIntRecv">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=4690:4733#L156">SingleIntRecv</a></h2>
			<pre>func SingleIntRecv(from_proc <a href="/pkg/builtin/#int">int</a>) (val <a href="/pkg/builtin/#int">int</a>)</pre>
			<p>
SingleIntRecv receives a single integer &#39;val&#39; from processor &#39;to_proc&#39;
</p>

			
			

		
			
			
			<h2 id="SingleIntSend">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=4530:4566#L150">SingleIntSend</a></h2>
			<pre>func SingleIntSend(val, to_proc <a href="/pkg/builtin/#int">int</a>)</pre>
			<p>
SingleIntSend sends a single integer &#39;val&#39; to processor &#39;to_proc&#39;
</p>

			
			

		
			
			
			<h2 id="Size">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=1243:1258#L55">Size</a></h2>
			<pre>func Size() <a href="/pkg/builtin/#int">int</a></pre>
			<p>
Size returns the number of processors
</p>

			
			

		
			
			
			<h2 id="Start">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=929:951#L32">Start</a></h2>
			<pre>func Start(debug <a href="/pkg/builtin/#bool">bool</a>)</pre>
			<p>
Start initialises MPI
</p>

			
			

		
			
			
			<h2 id="Stop">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=1036:1057#L41">Stop</a></h2>
			<pre>func Stop(debug <a href="/pkg/builtin/#bool">bool</a>)</pre>
			<p>
Stop finalises MPI
</p>

			
			

		
			
			
			<h2 id="SumToRoot">func <a href="https://github.com/cpmech/gosl/blob/master/mpi/mpi.go?s=1541:1577#L66">SumToRoot</a></h2>
			<pre>func SumToRoot(dest, orig []<a href="/pkg/builtin/#float64">float64</a>)</pre>
			<p>
SumToRoot sums all values in &#39;orig&#39; to &#39;dest&#39; in root (Rank == 0) processor
</p>
<pre>NOTE: orig and dest must be different slices, i.e. not pointing to the same underlying data structure
</pre>

			
			

		
		
	

	






<div id="footer">
<br /><br />
<hr>
<pre class="copyright">
Copyright (c) 2016, The Gosl Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

* Neither the name of Gosl nor the names of its
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

</pre><!-- copyright -->
</div><!-- footer -->

</div><!-- container -->
</div><!-- page -->
</body>
</html>
